package com.tjnu.baiyi.factory.util;

public class PageInfo {
	private Integer nowPage;// 当前显示页
	private Integer lastPage;// 上一页
	private Integer nextPage;// 下一页
	private Integer showNumber;// 显示的记录条数
	private Integer pageCount;// 总的页数

	// ////////////////////////////////////////////////////////////////////////////////////////////
	public PageInfo(Integer nowPage, Integer lastPage, Integer nextPage,
			Integer showNumber, Integer pageCount) {
		super();
		this.nowPage = nowPage;
		this.lastPage = lastPage;
		this.nextPage = nextPage;
		this.showNumber = showNumber;
		this.pageCount = pageCount;
	}

	public PageInfo(Integer lastPage, Integer nextPage, Integer showNumber,
			Integer pageCount) {
		super();
		this.lastPage = lastPage;
		this.nextPage = nextPage;
		this.showNumber = showNumber;
		this.pageCount = pageCount;
	}

	public PageInfo() {
		super();
		// TODO Auto-generated constructor stub
	}

	public PageInfo(Integer nowPage, Integer pageCount) {
		super();
		if (nowPage < 0) {
			this.nowPage = 0;
			this.lastPage = 0;
			this.nextPage = 1;
		} else if (nowPage >= pageCount) {
			this.nowPage = pageCount - 1;
			this.lastPage = pageCount - 2;
			this.nextPage = pageCount;
		} else {
			this.nowPage = nowPage;
			this.lastPage = nowPage - 1;
			this.nextPage = nowPage + 1;
		}
		this.pageCount = pageCount;
	}

	// ////////////////////////////////////////////////////////////////////////////////////////////

	public Integer getNowPage() {
		return nowPage;
	}

	public void setNowPage(Integer nowPage) {
		this.nowPage = nowPage;
	}

	public Integer getLastPage() {
		// if (nowPage == 0) {
		// lastPage = 0;
		// } else if (nowPage >= pageCount - 1) {
		// lastPage = nowPage - 1;
		// } else {
		// lastPage = nowPage - 1;
		// }
		return lastPage;
	}

	public void setLastPage(Integer lastPage) {
		this.lastPage = lastPage;
	}

	public Integer getNextPage() {
		return nextPage;
	}

	public void setNextPage(Integer nextPage) {
		this.nextPage = nextPage;
	}

	public Integer getShowNumber() {
		return showNumber;
	}

	public void setShowNumber(Integer showNumber) {
		this.showNumber = showNumber;
	}

	public Integer getPageCount() {
		return pageCount;
	}

	public void setPageCount(Integer pageCount) {
		this.pageCount = pageCount;
	}
}
